package com.lovo.user.mq;

import com.lovo.common.bean.User;
import com.lovo.common.util.MQUtil;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "shop.direct.queue")
public class DirectReceiver {
    @Autowired
    private MQUtil mqUtil;
    @RabbitHandler
    public void receive(String content, Message message, Channel channel){
        System.out.println("接收到消息：" + content);
        mqUtil.ack(message,channel);
    }
    @RabbitHandler
    public void receive(User user, Message message, Channel channel){
        System.out.println("接收到消息对象：" + user);
        mqUtil.ack(message,channel);
    }
}
